From 1eca78131b11b10341ec5c4630f34ffedf075c0f Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Tue, 17 Sep 2013 18:54:59 -0400 Subject: [PATCH] Store boolean values as integers with SQLite Since SQLite doesn't have a boolean type, and doesn't enforce types, make sure booleans get stored as integers, to prevent undesirable behavior, such as false values being stored as empty strings. Change-Id: I2a96065826412fa25f98ec298d806e73ebe155ba --- includes/db/DatabaseSqlite.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index 6692fa40ac..a8270bf4b3 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -709,6 +709,8 @@ class DatabaseSqlite extends DatabaseBase { function addQuotes( $s ) { if ( $s instanceof Blob ) { return "x'" . bin2hex( $s->fetch() ) . "'"; + } elseif ( is_bool( $s ) ) { + return (int)$s; } elseif ( strpos( $s, "\0" ) !== false ) { // SQLite doesn't support \0 in strings, so use the hex representation as a workaround. // This is a known limitation of SQLite's mprintf function which PDO should work around, -- 2.20.1